register ucsb.appscale.protoBuff.jar
register /root/software/apache-cassandra-0.7.4-src/lib/commons-lang-2.4.jar
register /root/software/apache-cassandra-0.7.4-src/lib/libthrift-0.5.jar
register /root/appscale/AppServer_Java/appengine-java-sdk-repacked/lib/impl/appengine-api.jar
register /root/software/apache-cassandra-0.7.4-src/lib/google-collections-1.0.jar

/*
user {name, city, state, sex}
logAction {user, action, timespan, sourceIp}
query: select sourceIp, sum(timespan) from logAction group by sourceIp;
*/

rows = LOAD 'cassandra://logAction_10/Standard1' USING org.apache.cassandra.hadoop.pig.CassandraStorage();
logRows = filter rows by $0 matches 'actionlogtests___LogAction.*';
logsMap = foreach logRows generate ucsb.appscale.protoBuff.Parse($1);
logs = foreach logsMap generate (int)$0#'sourceIp' as sourceIp, (double)$0#'timespan' as timespan;
groupIp = group logs by sourceIp;
dump groupIp;
results = foreach groupIp generate group, SUM(logs.timespan);
dump results;
